package com.example.demo.demos.web;

import com.deepoove.poi.data.*;
import com.deepoove.poi.data.style.TableStyle;
import lombok.Data;
import lombok.SneakyThrows;

import java.util.Map;

/**
 * @author Administrator
 * @describe: TODO
 * @date 2025/2/26
 */
@Data
public class GwydTable {
    @SneakyThrows
    public Map<String, Object> createGwydTable( Map<String, Object> datas  ) {
        RowRenderData row1 = Rows.of("工作\n" +
                "场所", "检测\n" +
                "岗位", "人数", "人数", "工作\n地点", "工作内容", "岗位\n作业\n类型", "工作\n班制", "工作时间\n" +
                "h/d*d/w", "岗位\n浓度\n类型")
            .textFontFamily("仿宋_GB2312")
            .repeatedHeader()
            .textBold()
            .center()
            .create();
        RowRenderData row2 = Rows.of("工作\n" +
                "场所", "检测\n" +
                "岗位", "人数", "人数", "工作\n地点", "工作内容", "岗位\n作业\n类型", "工作\n班制", "工作时间\n" +
                "h/d*d/w", "岗位\n浓度\n类型")
            .textFontFamily("仿宋_GB2312")
            .repeatedHeader()
            .textBold()
            .center()
            .create();
        RowRenderData row3 = Rows.of("生产车间", "开料工", "1", "1", "带锯工位", "操作带锯切割木料", "流动岗位", "一班制", "8*6", "②")
            .textFontFamily("仿宋_GB2312")

            .center()
            .create();
        RowRenderData row4 = Rows.of("生产车间", "开料工", "1", "1", "砂带机工位", "操作砂带打磨木料", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row5 = Rows.of("生产车间", "开料工", "1", "1", "锯管机工位", "操作锯管切割五金件", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row6 = Rows.of("生产车间", "开料工", "1", "1", "冲床工位", "操作冲床冲压五金件", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row7 = Rows.of("生产车间", "开料工", "1", "1", "钻床工位", "操作钻床五金件钻孔", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row8 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row9 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row10 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row11 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row12 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row13 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row14 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
                .create();
        RowRenderData row15 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
                .textFontFamily("仿宋_GB2312")
                .center()
            .create();
        RowRenderData row16 = Rows.of("生产车间", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
            .textFontFamily("仿宋_GB2312")
            .center()
            .create();
        RowRenderData row17 = Rows.of("备注：1.岗位浓度类型：①浓度/强度相对稳定岗位，②非浓度/强度相对稳定岗位。", "开料工", "1", "1", "铆钉机工位", "操作铆钉机五金件铆接", "流动岗位", "一班制", "8*6", "②")
            .textFontFamily("仿宋_GB2312")
            .center()
            .create();
        TableRenderData table = Tables.create(row1, row2, row3, row4, row5, row6, row7, row8, row9, row10, row11, row12, row13, row14, row15, row16, row17);
        TableStyle tableStyle = new TableStyle();
        tableStyle.setColWidths(new int[]{40, 60, 40, 40, 60, 80, 60, 60, 60, 60});
        table.setTableStyle(tableStyle);
        tableStyle.setWidth("100%"); // 设置表格总宽度

        MergeCellRule rule3 = MergeCellRule.builder()
            //合并第一行
            .map(MergeCellRule.Grid.of(0, 0), MergeCellRule.Grid.of(1, 0))
            .map(MergeCellRule.Grid.of(0, 1), MergeCellRule.Grid.of(1, 1))
            .map(MergeCellRule.Grid.of(0, 4), MergeCellRule.Grid.of(1, 4))
            .map(MergeCellRule.Grid.of(0, 5), MergeCellRule.Grid.of(1, 5))
            .map(MergeCellRule.Grid.of(0, 6), MergeCellRule.Grid.of(1, 6))
            .map(MergeCellRule.Grid.of(0, 7), MergeCellRule.Grid.of(1, 7))
            .map(MergeCellRule.Grid.of(0, 8), MergeCellRule.Grid.of(1, 8))
                .map(MergeCellRule.Grid.of(0, 9), MergeCellRule.Grid.of(1, 9))
                .map(MergeCellRule.Grid.of(0, 2), MergeCellRule.Grid.of(0, 3))
                // 合并第二行
                .map(MergeCellRule.Grid.of(2, 0), MergeCellRule.Grid.of(14, 0))
                // 合并第三行-第气行
                .map(MergeCellRule.Grid.of(2, 1), MergeCellRule.Grid.of(7, 1))
                .map(MergeCellRule.Grid.of(2, 2), MergeCellRule.Grid.of(7, 2))
                .map(MergeCellRule.Grid.of(2, 3), MergeCellRule.Grid.of(7, 3))

                .map(MergeCellRule.Grid.of(2, 6), MergeCellRule.Grid.of(7, 6))
                .map(MergeCellRule.Grid.of(2, 7), MergeCellRule.Grid.of(7, 7))
                .map(MergeCellRule.Grid.of(2, 8), MergeCellRule.Grid.of(7, 8))
                .map(MergeCellRule.Grid.of(2, 9), MergeCellRule.Grid.of(7, 9))
                // 合并尾行
                .map(MergeCellRule.Grid.of(16, 0), MergeCellRule.Grid.of(16, 9))
                .build();

        table.setMergeRule(rule3);
        datas.put("岗位定员", table);
         return datas;

    }

}
